package com.river.boot.system.converter;

import com.river.boot.common.base.Option;
import com.river.boot.system.model.entity.User;
import com.river.boot.system.model.form.UserProfileForm;
import com.river.boot.system.model.vo.UserProfileVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * 用户对象转换器
 *
 * @author Ray.Hao
 * @since 2022/6/8
 */
@Mapper(componentModel = "spring")
public interface UserConverter {

    @Mappings({
            @Mapping(target = "label", source = "nickname"),
            @Mapping(target = "value", source = "id")
    })
    Option<String> toOption(User entity);

    List<Option<String>> toOptions(List<User> list);

    UserProfileVO toProfile(User user);

    User toEntity(UserProfileForm formData);
}
